% function u = u0(x)
% 
% if x > pi/2 && x < 3*pi/2
%     u = 1;
% else
%     u = 0;
% end
% 
% end

% function u = u0(x)
% 
%     if x > pi/4 && x < pi/2
%         u = 1;
%     elseif x > pi && x < pi+0.2
%         u=1-abs(10*(x-pi-0.1));
%     else
%         u = 0;
%     end
% end
% 

function u = u0(x)
   
    a = 0.5;
    z = -0.7;
    delta = 0.005;
    phi = 10;
    psi = log(2) / (36 * delta^2);
    
   
    function val = G(x, psi, z)
        val = exp(-psi * (x - z)^2);
    end

    function val = F(x, phi, a)
        val = sqrt(max(1 - phi^2 * (x - a)^2, 0));
    end

  
    if x >= -0.8 && x <= -0.6
        u = (1/6) * (G(x, psi, z - delta) + G(x, psi, z + delta) + 4 * G(x, psi, z));
    elseif x >= -0.4 && x <= -0.2
        u = 1;
    elseif x >= 0 && x <= 0.2
        u = 1 - abs(10 * (x - 0.1));
    elseif x >= 0.4 && x <= 0.6
        u = (1/6) * (F(x, phi, a - delta) + F(x, phi, a + delta) + 4 * F(x, phi, a));
    else
        u = 0;
    end
end

